<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <title>K5G-C</title>
    <link rel="stylesheet" href="./css/common.css" />
    <link rel="stylesheet" href="./css/index.css" />
    <link rel="stylesheet" href="./css/wifi.css" />
</head>

<body>
    <div class="main">
        <div class="tit-heade">
            <div class="itemOne">
                <img src="./image/left.png" >
            </div>
            <div class="itemTwo">
                <div class="item-chil">
                    <img src="./image/logoutOne.png">
                </div>
                <div class="item-chil">
                    <a href="/action/logout">ログアウト</a>
                </div>
                
            </div>
        </div>  
        <div class="nav2" style="height: 285vh;">
            <div class="nav-item">
                <div id='x1' class="item" onclick="toPage('./home.html')">ホーム</div>
            </div>
            <div class="nav-item">
                <div id='x2' class="item no-act" onclick="toPage('./mobileData.html')">モバイルネットワーク</div>
            </div>
            <div class="nav-item">
                <div id='x3' class="item no-act" onclick="toPage('./wifi.html')">Wi-Fi設定</div>
                <div class="">
                    <div>
                        <div class="">
                            <div class="item1 choose" id="wifi1" onclick="toPage('./wifi.html')"> アクセスポイント設定</div>
                            <div class="item1" id="wifi2" onclick="toPage('./wifiList.html')"> Wi-Fi接続情報</div>
                            <div class="item1" id="wifi_list" onclick="toPage('./wifiManage.html')"> 接続デバイスの管理</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="nav-item">
                <div id='x4' class="item no-act" onclick="toPage('./dhcp.html')">Ethernet設定</div>
                <div class="hide">
                    <div>
                        <div id='x41' class="item1 no-act">DHCP固定割当設定</div>
                        <div class="">
                            <div class="item2" id="DHCP">DHCP固定割当設定</div>
                            <div class="item2" id="MAC">MAC IP Bindingリスト</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="nav-item">
                <div id='x5' class="item no-act" onclick="toPage('./port.html')">LAN設定</div>
                <div class="hide">
                    <div>
                        <div id='x51' class="item no-act">ポートフォワーディング</div>
                        <div class="hide">
                            <div class="item2" id="port">ポートフォワーディング</div>
                            <div class="item2" id="port_list">ポートフォワーディングリスト</div>
                        </div>
                    </div>
                    <div>
                        <div id='x52' class="item1 no-act">IPパケットフィルタリング</div>
                        <div class="hide">
                            <div class="item2" id="IP">IPパケットフィルタリング</div>
                            <div class="item2" id="IP_list">IPパケットフィルタリングリスト</div>
                        </div>
                    </div>
                    <div>
                        <div id='x53' class="item1 no-act"
                             onclick="toPage('./dmz.html')">
                            DMZ
                        </div>
                    </div>
                    <div>
                        <div id='x54' class="item1 no-act">IPV6パケットフィルタリング</div>
                        <div class="hide">
                            <div class="item2" id="IPV6">IPV6パケットフィルタリング</div>
                            <div class="item2" id="IPV6_list">IPV6パケットフィルタリングリスト</div>
                        </div>
                    </div>
                    <div>
                        <div id='x55' class="item1 no-act"
                             onclick="toPage('./dmz.html')">
                            WANポートPingブロック</div>
                    </div>
                </div>
            </div>
            <div class="nav-itm">
                <div id='x6' class="item no-act" onclick="toPage('./password.html')">端末設定</div>
                <div class="hide">
                    <div>
                        <div class="">
                            <div class="item" onclick="toPage('./password.html')">パスワード設定</div>
                            <div class="item" onclick="toPage('./dataUsage.html')">データ使用量</div>
                            <div class="item" onclick="toPage('./reboot.html')">リブート</div>
                            <div class="item" onclick="toPage('./deviceInformation.html')">デバイス情報</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div id="wifi" class="content" style="height: 280vh;">
            <div class="title">アクセスポイント設定</div>

            <div style="margin-left: 100px;margin-top: 10px;">
                <p>Wi-Fiアクセスポイントの設定ができます。</p>
                <p>　</p>
                <p>注意：</p>
                <p>・屋内と屋外では利用可能なWi-Fi周波数帯が異なります。</p>
                <p>　一部の周波数は、屋外で使用することが法令で禁止されています。</p>
                <p>　端末設定にて屋内/屋外モードを正しく設定して、ルーターを使用してください。</p>
                <p>・気象レーダーの電波干渉を確認するため、5GHzの無線が有効になるまでおよそ1分かかることがあります。</p>
            </div>

            <form action="" class="default-form">
                <table class="input-table">
                    <thead>
                        <tr>
                            <th class="start-restart-box"><label class="default-label" for="">Wi-Fiルーター</label></th>
                            <td class="start-restart-box">
                                <input type="checkbox" onclick="startAp()" name="sex" id="start-restart" class="chooseBtn" />
                                <label for="start-restart" class="choose-label"/>
                            </td>
                        </tr>
                    <thead>
                    <tbody>
                        <tr>
                            <th><label class="default-label" for="Wifi_name">アクセスポイント名</label></th>
                            <td><input type="text" class="default-input" name="wifi_name" id="wifi_name"
                                    /></td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="">セキュリティ</label></th>
                            <td>

                                <label style="display: block;">
                                    <input onclick="security_click(1)" class="a-radio" type="radio" name="security"
                                        value="8"><span class="b-radio"></span>WPA3 Personal
                                </label>
                                <label style="display: block;">
                                    <input onclick="security_click(1)" class="a-radio" type="radio" name="security"
                                        value="4" checked><span class="b-radio"></span>WPA2
                                    Personal
                                </label>
                                <!-- <label style="display: block;">
                                    <input onclick="security_click(2)" class="a-radio enhancedOpen" type="radio"
                                        name="security" value="9"><span class="b-radio"></span>Enhanced Open
                                </label> -->
                                <label style="display: block;">
                                    <input onclick="security_click(0)" class="a-radio" type="radio" name="security"
                                        value="0"><span class="b-radio"></span>None
                                </label>

                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="Wifi-password">パスワード</label></th>
                            <td><input type="text" class="default-input" name="wifi-password" id="wifi-password"
                                    />
                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="">屋内/屋外モード</label>
                            </th>
                            <td>
                                <label style="display: block;">
                                    <input onclick="ap_door_click(0)" class="a-radio" type="radio" name="door"
                                        value="0" checked><span class="b-radio"></span>屋内と屋外で利用
                                </label>
                                <label style="display: block;">
                                    <input onclick="ap_door_click(1)" class="a-radio" type="radio" name="door"
                                        value="1"><span class="b-radio"></span>屋内のみで利用
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="">利用周波数設定</label>
                            </th>
                            <td>
                                <label style="display: block;">
                                    <input onclick="ap_band_click(0)" class="a-radio" type="radio" name="ap-band"
                                        value="0" checked><span class="b-radio"></span>2.4GHz
                                </label>
                                <label style="display: block;">
                                    <input onclick="ap_band_click(1)" class="a-radio" type="radio" name="ap-band"
                                        value="1"><span class="b-radio"></span>5GHz
                                </label>
                                <label style="display: block;">
                                    <input onclick="ap_band_click(2)" class="a-radio bothHz" type="radio" name="ap-band"
                                        value="2"><span class="b-radio"></span>両方
                                </label>

                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="">2.4GHzのチャネル設定</label></th>
                            <td>
                                <select class="default-select" name="ap-channel-hz24" id="ap-channel-hz24">
                                    <option value="0">自動</option>
                                    <option class="ap-channel-0" value="1">1</option>
                                    <option class="ap-channel-0" value="2">2</option>
                                    <option class="ap-channel-0" value="3">3</option>
                                    <option class="ap-channel-0" value="4">4</option>
                                    <option class="ap-channel-0" value="5">5</option>
                                    <option class="ap-channel-0" value="6">6</option>
                                    <option class="ap-channel-0" value="7">7</option>
                                    <option class="ap-channel-0" value="8">8</option>
                                    <option class="ap-channel-0" value="9">9</option>
                                    <option class="ap-channel-0" value="10">10</option>
                                    <option class="ap-channel-0" value="11">11</option>
                                </select>
                            </td>
                        </tr>
                        <tr >
                            <th><label class="default-label" for="">5GHzのチャネル設定</label></th>
                            <td>
                                <select class="default-select" name="ap-channel-hz5" id="ap-channel-hz5-one">
                                    <option class="ap-channel-1" value="44">W56</option>
                                </select>
                                <select class="default-select" name="ap-channel-hz5" id="ap-channel-hz5-two">
                                    <option class="ap-channel-1" value="36">W52</option>
                                    <option class="ap-channel-1" value="40">W53</option>
                                    <option class="ap-channel-1" value="44">W56</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th> <label class="default-label" for="">アクセスポイントを自動的にオフにする</label></th>
                            <td>
                                <label style="display: block;">
                                    <input class="a-radio" type="radio" name="auto-close" value="1"
                                        onclick="auto_close_click(1)"><span class="b-radio"></span>ON
                                </label>
                                <label style="display: block;">
                                    <input class="a-radio" type="radio" name="auto-close" value="0"
                                        onclick="auto_close_click(0)" checked><span class="b-radio"></span>OFF
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="">自動OFF時間の設定</label></th>
                            <td>
                                <label style="display: block;">
                                    <input class="a-radio" type="radio" name="auto-close-time" disabled="true"
                                        value="0"><span class="b-radio"></span>なし
                                </label>
                                <label style="display: block;">
                                    <input class="a-radio" type="radio" name="auto-close-time" disabled="true"
                                        value="5"><span class="b-radio"></span>5分
                                </label>
                                <label style="display: block;">
                                    <input class="a-radio" type="radio" name="auto-close-time" disabled="true"
                                        value="10" checked><span class="b-radio"></span>10分
                                </label>
                                <label style="display: block;">
                                    <input class="a-radio" type="radio" name="auto-close-time" disabled="true"
                                        value="20"><span class="b-radio"></span>20分
                                </label>
                                <label style="display: block;">
                                    <input class="a-radio" type="radio" name="auto-close-time" disabled="true"
                                        value="30"><span class="b-radio"></span>30分
                                </label>
                                <label style="display: block;">
                                    <input class="a-radio" type="radio" name="auto-close-time" disabled="true"
                                        value="60"><span class="b-radio"></span>60分
                                </label>
                            </td>
                        </tr>

                    </tbody>
                </table>

                <div class="form-box" style="padding: 30px">
                    <div style="color: #333333; font:bold; font-size: 24px; border-bottom: 1px solid #000">高度な設定
                    </div>
                </div>

                <table class="input-table">
                    <tbody>
                        <tr>
                            <th><label class="default-label" for="">ステルス設定</label></th>
                            <td>
                                <label style="display: block;">
                                    <input class="a-radio" type="radio" name="invisible" value="1"><span
                                        class="b-radio"></span>ON
                                </label>
                                <label style="display: block;">
                                    <input class="a-radio" type="radio" name="invisible" value="0" checked><span
                                        class="b-radio"></span>OFF
                                </label>


                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="">DHCPサーバー</label></th>
                            <td>
                                <label style="display: block;">
                                    <input onclick="manuallySetting('1')" class="a-radio" type="radio" name="hand_auto"
                                        value="1"><span class="b-radio"></span>手動設定
                                </label>
                                <label style="display: block;">
                                    <input onclick="manuallySetting('0')" class="a-radio" type="radio" name="hand_auto"
                                        value="0" checked><span class="b-radio"></span>自動設定
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="gateway_ip">ホストIPアドレス</label></th>
                            <td>
                                <input type="text" disabled="false" class="default-input wifi-input" name="gateway_ip"
                                       id="gateway_ip" />
                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="start_ip">開始IPアドレス</label></th>
                            <td>
                                <input type="text" disabled="false" class="default-input wifi-input" name="start_ip"
                                    id="start_ip" />
                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="end_ip">終了IPアドレス</label></th>
                            <td>
                                <input type="text" disabled="false" class="default-input wifi-input" name="end_ip"
                                    id="end_ip" />
                            </td>
                        </tr>

                        <tr>
                            <th><label class="default-label" for="prefix_length">プレフィックス長</label></th>
                            <td>
                                <input oninput="value=value.replace(/[^\d]/g,'')" type="text" disabled="false"
                                    class="default-input wifi-input" name="prefix_length" id="prefix_length"
                                    />
                            </td>
                        </tr>

                        <tr>
                            <th><label class="default-label" for="">DNS設定</label></th>
                            <td>
                                <label style="display: block;">
                                    <input onclick="manuallySetting('1')" class="a-radio" type="radio" name="ap_dns_settings"
                                        value="1"><span class="b-radio"></span>ON
                                </label>
                                <label style="display: block;">
                                    <input onclick="manuallySetting('0')" class="a-radio" type="radio" name="ap_dns_settings"
                                        value="0" checked><span class="b-radio"></span>OFF
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="ap_dns1">プライマリDNS</label></th>
                            <td>
                                <input type="text" disabled="false" class="default-input wifi-input" name="ap_dns1"
                                       id="ap_dns1" />
                            </td>
                        </tr>
                        <tr>
                            <th><label class="default-label" for="ap_dns2">セカンダリDNS</label></th>
                            <td>
                                <input type="text" disabled="false" class="default-input wifi-input" name="ap_dns2"
                                       id="ap_dns2" />
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div class="horizontal-button">
                    <div onclick="apConfigSet()" id="save-wifi" class="button-common">設定</div>
                </div>
            </form>

        </div>
    </div>

    <script type="text/javascript" src="./js/utils.js"></script>
    <script>
        var channel5G = '0'
        var apBcastChannel = ''
        var apBcastChannel5G = ''
        window.onload = function () {
            getData()
            getSimNum()
            Ajax.get(baseUrl + '/action/apConfigGet', function (res) {
                var response = JSON.parse(res)
                var data = response.data
                if(data.apIndoorOutdoorMode == 0){
                    document.getElementById('ap-channel-hz5-two').style.display = 'none'
                    document.getElementById('ap-channel-hz5-one').style.display = 'block'
                }else{
                    document.getElementById('ap-channel-hz5-two').style.display = 'block'
                    document.getElementById('ap-channel-hz5-one').style.display = 'none'
                }
                if(data.apBand == 0){
                    ap_band_click(0)
                }else if(data.apBand == 1){
                    ap_band_click(1)
                }else{
                    ap_band_click(2)
                }
            })
        }

        function getSimNum() {
            var params = {}
            Ajax.post(baseUrl + '/action/getActiveSimCardNumber', JSON.stringify(params), function(res) {
                var response = JSON.parse(res)
                if (response.status == 'success') {
                    sessionStorage.setItem('activeSimNumber', response.data.activeSimNumber)
                }
            })

            var num = sessionStorage.getItem('activeSimNumber')
            if (num == 0) {
                var btn = document.getElementById('x2')
                btn.onclick = function() {}
                btn.style.backgroundColor = '#eee'
            }
            
        }
        function getData() {
            Ajax.get(baseUrl + '/action/apConfigGet', function (res) {
                var response = JSON.parse(res)
                if (response.status == 'success') {
                    var data = response.data
                    if (data.apStatus == "0") {
                        document.getElementById("start-restart").checked = false
                        document.getElementById("save-wifi").innerText = "保存"
                    } else if (data.apStatus == "1") {
                        document.getElementById("start-restart").checked = true
                        document.getElementById("save-wifi").innerText = "適用"
                    }
                    document.getElementById("wifi_name").value = data.apSSID || ''
                    Utils.SetRadioValue("security", data.apSecurityType || '0')
                    var securityValue = ["0", "9"]
                    if (securityValue.indexOf(data.apSecurityType) !== -1) {
                        document.getElementById("wifi-password").disabled = true
                    }
                    if(data.apSecurityType == "9"){
                        var bothHz = document.getElementsByClassName("bothHz")[0]
                        bothHz.disabled = true
                        bothHz.parentNode.style.color = "rgb(167, 167, 167)"
                    }
                    document.getElementById("wifi-password").value = data.apPassword || ''
                    Utils.SetRadioValue("ap-band", data.apBand || '0')
                    var ap_channel_0 = document.getElementsByClassName("ap-channel-0")
                    var ap_channel_1 = document.getElementsByClassName("ap-channel-1")

                    Utils.SetSelectValue("ap-channel-hz24", data.apBcastChannel || '0')
                    
                    Utils.SetRadioValue("auto-close", data.apAutoOffFlag || '0')
                    if(data.apIndoorOutdoorMode == 0){
                        Utils.SetSelectValue("ap-channel-hz5-one", '44' || '0')
                    }
                    if(data.apIndoorOutdoorMode == 1){
                        if(data.apBcastChannel5G == 'W52'){
                            Utils.SetSelectValue("ap-channel-hz5-two", '36' || '0')
                        }
                        if(data.apBcastChannel5G == 'W53'){
                            Utils.SetSelectValue("ap-channel-hz5-two", '40' || '0')
                        }
                        if(data.apBcastChannel5G == 'W56'){
                            Utils.SetSelectValue("ap-channel-hz5-two", '44' || '0')
                        }
                    }
                    Utils.SetRadioValue("door", data.apIndoorOutdoorMode || '0')
                    var radios = document.getElementsByName("auto-close-time");
                    if (data.apAutoOffFlag == "1") {
                        Utils.SetRadioStatus(radios, 1)
                    }
                    Utils.SetRadioValue("auto-close-time", data.apAutoOffTime || '10')
                    Utils.SetRadioValue("invisible", data.apHiddenSsid || '0')
                    Utils.SetRadioValue("hand_auto", data.apManualDhcp || '0')
                    var wifi_psw = document.getElementsByClassName("wifi-input")
                    if (data.apManualDhcp == "1") {
                        Utils.SetInputStatus(wifi_psw, 1)
                    }
                    document.getElementById("start_ip").value = data.apStartIp || ''
                    document.getElementById("end_ip").value = data.apEndip || ''
                    document.getElementById("gateway_ip").value = data.apDeviceIp || ''
                    document.getElementById("prefix_length").value = data.apNetmask || ''

                    Utils.SetRadioValue("ap_dns_settings", data.apDnsSettings || '0')
                    document.getElementById("ap_dns1").value = data.apDns1 || ''
                    document.getElementById("ap_dns2").value = data.apDns2 || ''
                } else {
                    Message.showmsg('処理に失敗しました')
                }
            })
        }
        function apConfigSet() {
            var securityValue = ["4", "8"]
            if (!document.getElementById("wifi_name").value) {
                Message.info('アクセスポイント名を入力してください')
                return false
            } else {
                var wifiNameByteCounts = getBytes(document.getElementById("wifi_name").value).bytesCount
                if (!(wifiNameByteCounts >= 1 && wifiNameByteCounts <= 32)) {
                    Message.info('アクセスポイント名は1〜32文字にする必要があります')
                    return false
                }
            }
            if (!document.getElementById("wifi-password").value) {
                if (securityValue.indexOf(Utils.GetRadioValue("security")) !== -1) {
                    Message.info('パスワードを入力してください')
                    return false
                }
            }else{
                var chineseStatus = getBytes(document.getElementById("wifi-password").value).chineseStatus
                if(chineseStatus == true){
                    Message.info('パスワードに無効な文字が設定されています')
                    return false
                }else{
                    var wifiPasswordByteCounts = getBytes(document.getElementById("wifi-password").value).bytesCount
                    if(!(wifiPasswordByteCounts>=8 && wifiPasswordByteCounts<=63)){
                        Message.info('アクセスポイント名は8〜63文字にする必要があります')
                        return false
                    }
                }
            }
            if (Utils.GetRadioValue("hand_auto") == 1) {
                if (!document.getElementById("start_ip").value) {
                    Message.info('開始IPアドレスを入力してください')
                    return false
                }
                if (!IPTest(document.getElementById("start_ip").value)) {
                    Message.info('開始IPアドレスが正しくありません')
                    return false
                }
                if (!document.getElementById("end_ip").value) {
                    Message.info('終了IPアドレスを入力してください')
                    return false
                }
                if (!IPTest(document.getElementById("end_ip").value)) {
                    Message.info('終了IPアドレスが正しくありません')
                    return false
                }
                if (!document.getElementById("gateway_ip").value) {
                    Message.info('ホストIPアドレスを入力してください')
                    return false
                }
                if (!IPTest(document.getElementById("gateway_ip").value)) {
                    Message.info('ホストIPアドレスが正しくありません')
                    return false
                }
                if (!document.getElementById("prefix_length").value) {
                    Message.info('プレフィックス長を入力してください')
                    return false
                }
                prefix_length = parseInt(document.getElementById("prefix_length").value)
                if (!(prefix_length >= 16 && prefix_length <= 30)) {
                    Message.info('プレフィックス長は16～30文字である必要があります')
                    return false
                }
            }
            // 这里应该有逻辑去判断 apDnsSettings和apDns1和apDns2的关系
            var ap_status = document.getElementById("start-restart").checked == true ? "0" : "1";
            var apRestart
            var save_wifi = document.getElementById("save-wifi")
            if (save_wifi.innerText == "保存") {
                apRestart = "0"
            } else if (save_wifi.innerText == "適用") {
                apRestart = "1"
            }
            let door_outdoor = Utils.GetRadioValue('door')
            let apBcastChannel5G = ''
            if(door_outdoor == 0){
                apBcastChannel5G = 'W56'
            }else{
                apBcastChannel5G = Utils.GetSelectValue("ap-channel-hz5-two")
                if(apBcastChannel5G == '36'){
                    apBcastChannel5G = 'W52'
                }
                if(apBcastChannel5G == '40'){
                    apBcastChannel5G = 'W53'
                }
                if(apBcastChannel5G == '44'){
                    apBcastChannel5G = 'W56'
                }
            }
            
            var params = {
                "apSSID": document.getElementById("wifi_name").value,
                "apSecurityType": Utils.GetRadioValue("security"),
                "apPassword": document.getElementById("wifi-password").value,
                "apBand": Utils.GetRadioValue("ap-band"),
                "apBcastChannel": Utils.GetSelectValue("ap-channel-hz24"),
                "apBcastChannel5G": apBcastChannel5G,
                "apAutoOffFlag": Utils.GetRadioValue("auto-close"),
                "apAutoOffTime": Utils.GetRadioValue("auto-close-time"),
                "apHiddenSsid": Utils.GetRadioValue("invisible"),
                "apManualDhcp": Utils.GetRadioValue("hand_auto"),
                "apStartIp": document.getElementById("start_ip").value,
                "apEndip": document.getElementById("end_ip").value,
                "apDeviceIp": document.getElementById("gateway_ip").value,
                "apNetmask": document.getElementById("prefix_length").value,
                "apStatus": ap_status,
                "apRestart": apRestart,
                "apDnsSettings": Utils.GetRadioValue("ap_dns_settings"),
                "apDns1": document.getElementById("ap_dns1").value,
                "apDns2": document.getElementById("ap_dns2").value,
                "apIndoorOutdoorMode":Utils.GetRadioValue('door')
            }
            Ajax.post(baseUrl + '/action/apConfigSet', JSON.stringify(params), function (res) {
                var response = JSON.parse(res)
                if (response.status == 'success') {
                    setTimeout(function () {
                        window.location.reload()
                    }, 1000);
                    Message.info('設定しました')
                } else {
                    Message.showmsg('処理に失敗しました')
                }
            })
        }
        function startAp() {
            var band = Utils.GetRadioValue("ap-band")
            var targetStatus = document.getElementById("start-restart").checked == true ? "1" : "0";
            var params = {
                targetStatus: targetStatus
            }
            Ajax.post(baseUrl + '/action/startAp', JSON.stringify(params), function (res) {
                var response = JSON.parse(res)
                if (response.status == 'success') {
                    // var dn = document.getElementsByClassName("mask")[0]
                    // dn.parentNode.removeChild(dn);
                    Message.info('設定しました')
                    setTimeout(function () {
                        getData()
                    }, 1000);
                } else {
                    Message.showmsg('処理に失敗しました')
                }
            })
        }

        function ap_band_click(data) {
            var ap_channel_0 = document.getElementsByClassName("ap-channel-0")
            var ap_channel_1 = document.getElementsByClassName("ap-channel-1")
            var ap_channel_hz24 = document.getElementById("ap-channel-hz24")
            var ap_channel_hz5 = document.getElementById("ap-channel-hz5")
            var ap_channel_0_common = ["0", '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11']
            var ap_channel_1_common = ["36", '40', '44', '48', '52', '56', '60', '64', '100', '104', '108', '112', '116', '120', '124', '128', '132', '136', '140']
            var enhancedOpen = document.getElementsByClassName("enhancedOpen")[0]
            // 2.4GHz
            if (data == 0) {
                // if (ap_channel_0_common.indexOf(ap_channel_hz5.value) == -1) {
                //     ap_channel_hz5.value = "44"
                // }
                for (var i = 0; i < ap_channel_0.length; i++) {
                    ap_channel_0.item(i).style.display = "block"
                }
                for (var i = 0; i < ap_channel_1.length; i++) {
                    ap_channel_1.item(i).style.display = "none"
                }
                enhancedOpen.disabled = false
                enhancedOpen.parentNode.style.color = "#000"
            } else if (data == 1) {
                // 5GHz
                // if (ap_channel_1_common.indexOf(ap_channel_hz24.value) == -1) {
                //     ap_channel_hz24.value = "0"
                // }
                for (var i = 0; i < ap_channel_0.length; i++) {
                    ap_channel_0.item(i).style.display = "none"
                }
                for (var i = 0; i < ap_channel_1.length; i++) {
                    ap_channel_1.item(i).style.display = "block"
                }
                enhancedOpen.disabled = false
                enhancedOpen.parentNode.style.color = "#000"
            } else if (data == 2) {
                // 両方
                for (var i = 0; i < ap_channel_0.length; i++) {
                    ap_channel_0.item(i).style.display = "block"
                }
                for (var i = 0; i < ap_channel_1.length; i++) {
                    ap_channel_1.item(i).style.display = "block"
                }
                enhancedOpen.disabled = true
                enhancedOpen.parentNode.style.color = "rgb(167, 167, 167)"
            }
        }

        function ap_door_click(data){
            Message.info('屋内と屋外では利用可能な周波数帯が異なり、一部の周波数は、屋外で使用すると法令違反になります。屋内/屋外モードを正しく設定することで法令に遵守してご利用いただくことができます。')
            channel5G = data
            var ap_channel_hz5 = document.getElementById("ap-channel-hz5")
            if(data == '0' ){
                document.getElementById('ap-channel-hz5-two').style.display = 'none'
                document.getElementById('ap-channel-hz5-one').style.display = 'block'
            }
            if(data == '1'){
                document.getElementById('ap-channel-hz5-two').style.display = 'block'
                document.getElementById('ap-channel-hz5-one').style.display = 'none'
            }
        }
        function security_click(data) {
            var wifi_psw = document.getElementById("wifi-password")
            var bothHz = document.getElementsByClassName("bothHz")[0]
            if (data == 0) {
                wifi_psw.disabled = true
                bothHz.disabled = false
                bothHz.parentNode.style.color = "#000"
            } else if (data == 1) {
                wifi_psw.disabled = false
                bothHz.disabled = false
                bothHz.parentNode.style.color = "#000"
            } else if (data == 2) {
                wifi_psw.disabled = true
                bothHz.disabled = true
                bothHz.parentNode.style.color = "rgb(167, 167, 167)"
            }
        }
        function manuallySetting(data) {
            var wifi_psw = document.getElementsByClassName("wifi-input")
            Utils.SetInputStatus(wifi_psw, data)
        }
        function auto_close_click(data) {
            var radios = document.getElementsByName("auto-close-time");
            Utils.SetRadioStatus(radios, data)
        }

    </script>
</body>

</html>
